<template>
  <div class="good-item">
    <!-- 监听图片加载 -->
    <img
      v-if="isDetailMsg"
      :src="item.show.img"
      @load="imgLoad"
      @click="ShowDetailPagesClick"
    />
    <img v-else :src="item.image" @click="CorrelationDetailPagesClick" />
    <div>
      <p id="title">{{ item.title }}</p>
      <span class="price">{{ item.price }}</span>
      <span>★{{ item.cfav }}</span>
    </div>
  </div>
</template>

<script>
export default {
  name: "GoodsListItem",
  props: {
    item: { 
      type: Object,
      deafult: null,
    },
    isDetailMsg: {
      type: Boolean,
    },
  },
  methods: {
    //跳转详情页
    CorrelationDetailPagesClick() {
      this.$router.push("/detail/" + this.item.item_id);
    },
    ShowDetailPagesClick() {
      this.$router.push("/detail/" + this.item.iid);
    },
    imgLoad() {
      this.$bus.$emit("imgLoad");
    },
    
  },
};
</script>

<style>
span {
  font-size: 16px;
}
.price {
  color: red;
  margin-right: 10px;
}
.good-item img {
  width: 160px;
  height: 250px;
  border-radius: 5px;
  box-shadow: 0px -1px 10px 1px rgba(0, 0, 0, 0.3);
}
#title {
  color: rgba(0, 0, 0, 0.6);
  padding: 0 7px 0 7px;
  font-size: 16px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

.good-item {
  text-align: center;
  flex: 0 0 50%;
  margin-bottom: 10px;
}
</style>